// my_custom_msgs_sub.cpp
#include <rclcpp/rclcpp.hpp>
#include "my_custom_msgs/msg/my_custom_msg.hpp"

class CustomMsgSubscriber : public rclcpp::Node {
public:
    CustomMsgSubscriber() : Node("custom_msg_subscriber") {
        subscription_ = this->create_subscription<my_custom_msgs::msg::MyCustomMsg>(
            "custom_topic", 10, std::bind(&CustomMsgSubscriber::topic_callback, this, std::placeholders::_1));
    }

private:
    void topic_callback(const my_custom_msgs::msg::MyCustomMsg::SharedPtr msg) const {
        RCLCPP_INFO(this->get_logger(), "Received: id=%d, name=%s, value=%f",
                    msg->id, msg->name.c_str(), msg->value);
    }

    rclcpp::Subscription<my_custom_msgs::msg::MyCustomMsg>::SharedPtr subscription_;
};

int main(int argc, char * argv[]) {
    rclcpp::init(argc, argv);
    rclcpp::spin(std::make_shared<CustomMsgSubscriber>());
    rclcpp::shutdown();
    return 0;
}
